package ssllink

import (
	"bufio"
	"crypto/tls"
	"slapp3/backend/application/domain"
	"slapp3/backend/config"

	"go.uber.org/zap"
)

type Sslink struct {
	Session *Session
	log     *zap.Logger
	config  *config.Config
	Conn    *tls.Conn // tls.Conn 是结构体，net.Conn 是接口，所以这里可以用指针类型
	BufR    *bufio.Reader
}

// NewSslink creates a new instance of Sslink
func NewSslink(logger *zap.Logger, cfg *config.Config) *Sslink {
	return &Sslink{
		log:     logger,
		Session: nil,
		config:  cfg,
	}
}

func (s *Sslink) SetProfile(profile *domain.Profile) {
	Prof.Host = profile.Host
	Prof.Username = profile.Username
	Prof.Password = profile.Password
	Prof.Group = profile.Group
	Prof.SecretKey = profile.SecretKey
	Prof.InsecureSkipVerify = profile.InsecureSkipVerify
	Prof.NoDTLS = profile.NoDTLS
	Prof.Version = profile.Version

	s.log.Info("Profile set", zap.String("host", Prof.Host), zap.String("username", Prof.Username))
}
